<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <div class="parent">
        <div class="test"></div>
    </div>
    <div class="parent1">
        <div class="test1"></div>
    </div>
    <div class="parent2">
        <div class="test2"></div>
    </div>
</body>
</html>
<script>
    
</script>
<style>
/* 第1种 */
.parent{
    width: 200px;
    height: 200px;
    box-sizing: border-box;
    border: 1px solid black;
    padding-left: 50px;
    padding-top: 50px;
}
.test{
    box-sizing: border-box;
    width: 100px;
    height: 100px;
    background: violet;
}
/* 第2种 */
.parent1{
    width: 200px;
    height: 200px;
    box-sizing: border-box;
    border: 1px solid black;
    position: relative;
}
.test1{
    width: 100px;
    height: 100px;
    background: seagreen;
    position: absolute;
    left: 25%;
    top: 25%;
}
/* 第3种 */
.parent2{
    width: 200px;
    height: 200px;
    box-sizing: border-box;
    border: 1px solid black;
    position: relative;
}
.test2{
    width: 100px;
    height: 100px;
    background: gold;
    position: absolute;
    bottom: 50px;
    right: 50px;
}
</style>